/*
 * F8.c
 *
 *  Created on: 21/10/2012
 *      Author: Sarah
 */

#include "F8.h"

double F8minX = -100;
double F8maxX = 100;
int F8dimensions = 1000;
int nonSeparableGroupSize = 50;

double compute(double* x) {
	int i;
	double result;

	double* F8Ovector = createShiftVector(F8dimensions, F8minX, F8maxX);
	double* F8anotherz = malloc(sizeof(double) * F8dimensions);
	double* F8anotherz1 = malloc(sizeof(double) * F8dimensions);
	double* F8anotherz2 = malloc(sizeof(double) * F8dimensions);

	int*Pvector = createPermVector(F8dimensions);

	for (i = 0; i < F8dimensions; i++) {
		F8anotherz[i] = x[i] - F8Ovector[i];
	}

	for (i = 0; i < nonSeparableGroupSize; i++) {
		F8anotherz1[i] = F8anotherz[Pvector[i]];
	}

	for (i = nonSeparableGroupSize; i < F8dimensions; i++) {
		F8anotherz2[i - nonSeparableGroupSize] = F8anotherz[Pvector[i]];
	}

	result = rosenbrock(F8anotherz1, nonSeparableGroupSize) * 1e6
			+ sphere(F8anotherz2, F8dimensions - nonSeparableGroupSize);

	free(F8Ovector);
	free(F8anotherz);
	free(F8anotherz1);
	free(F8anotherz2);

	return (result);
}

int F8GetF8dimensionss() {
	return F8dimensions;
}
double F8GetGetMax() {
	return F8maxX;
}
double F8GetMin() {
	return F8minX;
}
